package com.tracesystem.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tracesystem.commons.Result;
import com.tracesystem.controller.Info.AllSeverityPageInfo;
import com.tracesystem.controller.Info.AllTypePageInfo;
import com.tracesystem.controller.form.*;
import com.tracesystem.dao.IssueSeverityDao;
import com.tracesystem.dao.IssueTypeDao;
import com.tracesystem.model.IssueSeverity;
import com.tracesystem.model.IssueType;
import com.tracesystem.service.IssueSeverityService;
import com.tracesystem.service.IssueTypeService;
import com.tracesystem.util.WoniuCopyUtil;
import com.tracesystem.util.exception.IssueSeverityException;
import com.tracesystem.util.exception.IssueTypeException;
import com.tracesystem.util.exception.code.IssueSeverityExceptionCode;
import com.tracesystem.util.exception.code.IssueTypeExceptionCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Kevin Martin
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/issueSeverity")
@Api(tags = "缺陷严重程度相关接口 如更新、新增、删除、查询")
public class IssueSeverityController {
    /**
     * 缺陷严重程度业务层对象
     */
    @Resource
    private IssueSeverityService issueSeverityService;

    /**
     * 缺陷严重程度实现层对象
     */
    @Resource
    private IssueSeverityDao issueSeverityDao;

    /**
     * 添加严重程度分类
     * @param addSeverityForm
     * @return
     */
    @ApiOperation("新增严重程度分类")
    @PostMapping("/addSeverity")
    public Result<?> addSeverity(@Valid @RequestBody AddSeverityForm addSeverityForm){
        return issueSeverityService.insertSeverity(addSeverityForm);
    }

    /**
     * 删除严重程度分类项
     * @param removeSeverityForm
     * @return
     */
    @ApiOperation("删除严重程度分类")
    @PostMapping("/removeSeverity")
    public Result<?> removeSeverity(@RequestBody RemoveSeverityForm removeSeverityForm){
        return issueSeverityService.delectSeverity(removeSeverityForm);
    }

    /**
     * 批量删除严重程度分类项
     * @param removeSeverityListForm
     * @return
     */
    @ApiOperation("批量删除严重程度分类")
    @PostMapping("/removeSeverityList")
    public Result<?> removeSeverityList(@RequestBody RemoveSeverityListForm removeSeverityListForm){
        return issueSeverityService.delectSeverityList(removeSeverityListForm);
    }

    /**
     * 修改严重程度分类
     * @param renewalSeverityDescForm
     * @return
     */
    @ApiOperation("修改严重程度分类")
    @PostMapping("/renewalSeverityDesc")
    public Result<?> renewalSeverityDesc(@RequestBody RenewalSeverityDescForm renewalSeverityDescForm){
        return issueSeverityService.updateSeverityDesc(renewalSeverityDescForm);

    }

    /**
     * 修改严重程度分类项
     * @param renewalSeverityModuleStateForm
     * @return
     */
    @ApiOperation("修改严重程度状态：禁用/启用")
    @PostMapping("/renewalSeverityModuleState")
    public Result<?> renewalSeverityModuleState(@RequestBody RenewalSeverityModuleStateForm renewalSeverityModuleStateForm){
        return issueSeverityService.updateSeverityModuleState(renewalSeverityModuleStateForm);
    }
    /**
     * 模糊查询严重程度分类
     * @param likeSeverityListForm
     * @return
     */
    @ApiOperation("模糊查询严重程度分类")
    @PostMapping("/likeSeverityList")
    public Result<AllSeverityPageInfo> likeSeverityList(@RequestBody LikeSeverityListForm likeSeverityListForm){
        return issueSeverityService.findPageSeverityListBySeverityDesc(likeSeverityListForm);
    }

    /**
     * 查询所有严重程度分类
     * @param findAllSeverityListForm
     * @return
     */
    @ApiOperation("查询所有严重程度分类")
    @PostMapping("/findAllSeverityList")
    public Result<AllSeverityPageInfo> findAllSeverityList(@RequestBody FindAllSeverityListForm findAllSeverityListForm){
        return issueSeverityService.getAllTypeList(findAllSeverityListForm);
    }
}

